package ssh

import (
	"context"
	"gitee.com/kristas/booting-go/framework/core/ioc/bean_factory"
	"gitee.com/kristas/booting-go/framework/core/log"
	"golang.org/x/crypto/ssh"
	"net"
)

type Dialer struct {
	client *ssh.Client
	_      *context.Context
}

func NewDialer(client *Client) *Dialer {
	return &Dialer{client: client.Client}
}

func (r *Dialer) Dial(context context.Context, addr string) (net.Conn, error) {
	logger := bean_factory.GetApplicationContext().GetBeanByInterface(new(log.Logger)).(log.Logger)
	logger.Info("[SSH] Dial [%s]", addr)
	return r.client.Dial("tcp", addr)
}
